// Ofri Keidar 302933981 group 05

package model;

import java.util.List;
import java.util.Map;
import model.apartment.*;
import model.building.Building;
import model.database.DBException;

/**
 * Interface of system's model. Class that implements this interface should manage system's database and support queries. 
 */
public interface Model {

	/**
	 * Returns all vacant flats in all the buildings in system. 
	 * Flats are sorted by area in ascending order
	 * @return list of wanted flats
	 * @throws DBException- throws database exception if database encountered a problem
	 */
	public List<Flat> getVacantFlats() throws DBException;
	
	/**
	 * Returns all vacant flats with given number of rooms, searching in all system's buildings.
	 * Flats are sorted by total area in ascending order
	 * @param roomNum- room number to search for
	 * @return list of wanted flats
	 * @throws DBException- throws database exception if database encountered a problem
	 */
	public List<Flat> getVacantFlats(double roomNum) throws DBException;
	
	/**
	 * Returns all vacant flats with given number of rooms at given address.
	 * Flats are sorted by total area in ascending order
	 * @param roomNum- room number to search for
	 * @param stName- name of building's street
	 * @param bldNumber- number of building on street
	 * @return list of wanted flats
	 * @throws DBException- throws database exception if database encountered a problem
	 */
	public List<Flat> getVacantFlats(double roomNum, String stName, int bldNumber) throws DBException;
	
	/**
	 * Returns all flats at given address 
	 * Flats are sorted by total area in ascending order
	 * @param stName- name of building's street
	 * @param bldNumber- number of building on street
	 * @return list of wanted flats
	 * @throws DBException- throws database exception if database encountered a problem
	 */
	public List<Flat> getFlats(String stName, int bldNumber) throws DBException;
	
	/**
	 * Returns all flats in all buildings in system
	 * Flats are sorted by total area in ascending order
	 * @return list of all flats
	 * @throws DBException- throws database exception if database encountered a problem
	 */	
	public List<Flat> getAllFlats() throws DBException;
	
	/**
	 * Returns all penthouses in all buildings in system
	 * Penthouses are sorted by total area in ascending order
	 * @return list of all penthouses
	 * @throws DBException- throws database exception if database encountered a problem
	 */
	public List<Penthouse> getAllPenthouses() throws DBException;
	
	/**
	 * Returns all garden apartments in all buildings in system
	 * Garden apartments are sorted by total area in ascending order
	 * @return list of all garden apartments
	 * @throws DBException- throws database exception if database encountered a problem
	 */
	public List<GardenApartment> getAllGardenAprtmnts() throws DBException;
	
	/**
	 * Returns building at given address.
	 * If such building is found, the building is returned. Otherwise, null is returned
	 * @param stName- name of building's street
	 * @param bldNumber- number of building on street
	 * @return building at given address or null if there is not a building at given address
	 * @throws DBException- throws database exception if database encountered a problem
	 */
	public Building getBuilding(String stName, int bldNumber)
			throws DBException;
	
	/**
	 * Returns all vacant apartments in system.
	 * Apartments are sorted by total area in ascending order
	 * @return list of all vacant apartments
	 * @throws DBException- throws database exception if database encountered a problem
	 */
	public List<Apartment> getVacantApartments() throws DBException;
	
	/**
	 * Returns all vacant apartments at given address.
	 * 	 * Apartments are sorted by total area in ascending order
	 * @return list of vacant apartments at given address
	 * @throws DBException- throws database exception if database encountered a problem
	 */
	public List<Apartment> getVacantApartments(String stName, int bldNumber)
			throws DBException;
	
	/**
	 * Checks if given parameters for the new apartment are of correct format.
	 * Verification is made according to given apartment type
	 * @param apartmentType- type of the new apartment
	 * @param parameters- parameters to be checked
	 * @return True if parameters are of correct format, False if not
	 */
	public boolean checkApartmentsParameters(String apartmentType,
			Map<String, String> parameters);
	
	/**
	 * Gets the type and parameters of each apartment and building's address. Creates a new building with given data.
	 * If could create the building, returns True. Otherwise, returns False  
	 * @param apartmentTypes- list of types for each apartment
	 * @param parameterList- list that holds the parameter map for each apartment 
	 * @param stName- buiding's street name
	 * @param bldNumber- building's number on street
	 * @return True if could add such building, False if not
	 * @throws DBException- throws database exception if database encountered a problem
	 */
	public boolean addNewBuilding(List<String> apartmentTypes,
			List<Map<String, String>> parameterList, String stName,
			int bldNumber) throws DBException;
	
	/**
	 * Updates given resident name of apartment at given address.
	 * If there is no building at given address or no apartment with given number in the building, no update is done 
	 * and False is returned. 
	 * Otherwise, updates data and True is returned
	 * @param stName- street name of apartment's address
	 * @param bldNum- building number where the apartment is 
	 * @param apartmentNum- apartment's number in the building
	 * @param newResident- new resident name
	 * @return True if updated successfully, False if not
	 * @throws DBException- throws database exception if database encountered a problem
	 */
	public boolean updateResident(String stName, int bldNumber,
			int apartmentNum, String newResident) throws DBException;
}